/**
 * @copyright (C) COPYRIGHT 2022 Fortiortech Shenzhen
 * @file      MyProject.h
 * @author    Fortiortech Appliction Team
 * @note      Last modify author is Marcel He
 * @since     2017-12-27
 * @date      2022-07-14
 * @brief     This file contains all the common data types used for Motor Control.
 *
 */

#ifndef LIN_H
#define LIN_H

#include <FU68xx_6_MCU.h>

/*------LIN选择的是DMA0还是DMA1------*/
#define     LIN_DMA_Pipe            0                               //默认为DMA1

/*------LIN选择是否开启中断以及中断优先级选择------*/
#define     LIN_IRQ_L1              0                               //1级
#define     LIN_IRQ_L2              0x10                            //2级
#define     LIN_IRQ_L3              0x20                            //3级
#define     LIN_IRQ_L4              0x30                            //4级

#define LINRW_R                 ClrBit(LIN_CR, LINRW)               // read data from master
#define LINRW_W                 SetBit(LIN_CR, LINRW)               // write data to master

/* 设置DMA传输地址*/
#define LIN_SETADDR(ADDR)       if(ReadBit(LIN_CR , DMASEL))      DMA1_BA  = ADDR;    \
    else  DMA0_BA  = ADDR

/* set the size of data, SIZE: 0~8*/
#define LIN_SETSIZE(SIZE)       LIN_SIZE = SIZE


/* acknowledge */
#define LIN_SETACK()            SetBit(LIN_CSR, LINACK)


extern uint8 xdata ucaLinBuff[8];

void LIN_Init(void);
void LIN_Schdule(void);

extern void LIN_Error_Handing(void);

#endif